package org.forex.impl.ws;

import java.io.IOException;
import java.util.HashMap;
import java.util.Optional;

import org.forex.vo.Instrument;
import org.forex.vo.Instruments;

public class GetInstruments extends AbstractHttpCallImpl<Instruments> {

	public GetInstruments() {
		super(Instruments.class);
		parameters=new HashMap<String, String>();
		parameters.put("accountId", "9646994");
	}

	public Optional<Instruments> getAll() throws IOException{
		return call("/v1/instruments");
	}
	
	public Optional<Instrument> get(String code) throws IOException{
		parameters.put("instruments", code);
		
		Optional<Instruments> res=call("/v1/instruments");
		
		if(res.isPresent())
			return Optional.ofNullable(res.get().getInstruments().get(0)); 
		
		return Optional.empty();
	}

	@Override
	public String getHttpMethod() {
		return GET;
	}

}
